<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function load(){
			//1.初始化对象
			let xhr=new XMLHttpRequest()
			//2.初始化请求(请求什么数据？)
			xhr.open("GET","data.text",true)
			//3.发送请求
			xhr.send()
			//4.接收数据，解析数据，显示数据
			xhr.onreadystatechange=function(){
				if(xhr.readyState==4&&xhr.status==200){
					let data=xhr.responseText
					document.querySelector("span").textContent=data
				}
			}
			}
		</script>
	</head>
	<body>
		异步请求文本的数据是：<span></span><br>
		<button type="button" onclick="load()">传输数据</button>
	</body>
</html>
